using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using com.paypal.sdk.profiles;
using log4net;

namespace IGlobalist.Cms.Common
{
    public class SetProfilePaypal
    {
        /// <summary>
        /// Required designer variable.
        /// </summary
        //public static readonly IAPIProfile DefaultProfile = CreateAPIProfile(Constants.API_USERNAME, Constants.API_PASSWORD, Constants.API_SIGNATURE, "", "", Constants.CERTIFICATE, Constants.PRIVATE_KEY_PASSWORD);

        public static IAPIProfile CreateAPIProfile(string apiUsername, string apiPassword, string signature, string enviroment, string CertificateFile_Sig, string APISignature_Sig, string CertificateFile_Cer, string PrivateKeyPassword_Cer)
        {
            //IAPIProfile profile = ProfileFactory.CreateAPIProfile();

            //if (Global.is3token == true)
            //{
            try
            {
                IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
                profile.APIUsername = apiUsername;
                profile.APIPassword = apiPassword;


                profile.Environment = enviroment;

                profile.Subject = string.Empty;
                profile.APISignature = signature;
                return profile;
            }
            catch (Exception e)
            {
                Global.log.Error("[[]]", e);
                throw e;
            }
            //}
            //else
            //{
            //    IAPIProfile profile = ProfileFactory.createSSLAPIProfile();
            //    profile.APIUsername = apiUsername;
            //    profile.APIPassword = apiPassword;
            //    profile.Environment = Constants.ENVIRONMENT;

            //    profile.CertificateFile = CertificateFile_Cer;
            //    profile.PrivateKeyPassword = PrivateKeyPassword_Cer;
            //    profile.Subject = signature;
            //    //profile.Subject = string.Empty;
            //    //profile.APISignature = signature;
            //    return profile;
            //}



        }
       

        public static IAPIProfile SessionProfile
        {
            get
            {
                return (IAPIProfile)HttpContext.Current.Session[Constants.PROFILE_KEY];
            }
            set
            {
                HttpContext.Current.Session[Constants.PROFILE_KEY] = value;
            }
        }
    }
}
